package Learn;

import myio.StringOps;

import org.dom4j.Document;
import org.dom4j.Element;
import org.dom4j.io.SAXReader;

public class Configuration {
	
	String rscript;
	String datamatrix;
	String rcodehome;
	int[] layerstruc;
    String[] layerstructype;
	String outputhome;
	int maxit;
	
	public Configuration(String configfile){
		try{
			SAXReader reader = new SAXReader();
			Document doc = reader.read(configfile);
			Element root = doc.getRootElement();
			Element configs = root.element("settings");
			
			rscript = configs.attributeValue("rscript");
			datamatrix = configs.attributeValue("datamatrix");
			rcodehome = configs.attributeValue("rcodehome");
			outputhome = configs.attributeValue("outputhome");
			layerstruc = StringOps.stringToIntArray(configs.attributeValue("layerstruc"));
			layerstructype = StringOps.stringToStringArray(configs.attributeValue("layerstructype"));
			maxit = Integer.parseInt(configs.attributeValue("maxit"));
			
		}
		catch (Exception e) {
			System.err.println(e);
		}
	}
	
	public String rscript(){
		return rscript;
	}
	public String datamatrix(){
		return datamatrix;
	}
	public String rcodehome(){
		return rcodehome;
	}
	public String outputhome(){
		return outputhome;
	}
	public int[] layerstruc(){
		return layerstruc;
	}
	public String[] layerstructype(){
		return layerstructype;
	}
	public int maxit(){
		return maxit;
	}
	

}
